class Students(object):
    def __init__(self, name, age):
        self.name = name
        self._age = age

    def get_age(self):
        return self._age

    def set_age(self, newage):
        if newage > 18:
            print("超过18岁了，不行")
        else:
            self._age = newage
    age = property(get_age, set_age)

if __name__ == '__main__':
    xm = Students("小明",15)
    print(xm.age)
    xm.age = 22
    print(xm.age)
    xm.age = 18
    print(xm.age)